<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
    <style>
        html,
        body {
            height: 100%;
            width: 100%;
            margin: 0 auto;
            padding: 0;
        }

        #myCanvas {
            background-color: #004834;
            /* height: 100%;
            width: 100%; */
        }
    </style>

</head>

<body>

    <canvas id="myCanvas" width="600px" height="400px" style="border:1px solid #d3d3d3;">

        <script>

            $(function () {

                var width = $(window).width();
                var height = $(window).height();

                var canvas = document.getElementById("myCanvas");

                $("#myCanvas").attr('width', width);
                $("#myCanvas").attr('height', height);

                var ctx = canvas.getContext("2d");
                canvas.onmousedown = function (e) {
                    var e = e || event;
                    var ox = e.clientX - canvas.offsetLeft;
                    var oy = e.clientY - canvas.offsetTop;
                    ctx.moveTo(ox, oy);

                    document.onmousemove = function (e) {
                        var ox2 = e.clientX - canvas.offsetLeft;
                        var oy2 = e.clientY - canvas.offsetTop;
                        ctx.lineTo(ox2, oy2);
                        ctx.strokeStyle = "white";
                        ctx.lineWidth = 3;
                        ctx.stroke();
                    }

                    document.onmouseup = function (e) {
                        document.onmousemove = null;
                        document.onmouseup = null;
                    }
                }

            });


        </script>

</body>

</html>